#include <iostream>
#include <cstring>

class Student
{
public:
    // 无参构造
    Student()
    {
        std::cout<<"无参构造\n";
    }
    // 带参构造
    Student(int age, const std::string & name)
    {
        m_age = age;
        m_name = name;
        std::cout<<"带二构造\n";
    }
    Student(const std::string & name)
    {
        m_age = 0;
        m_name = name;
        std::cout<<"带一构造\n";
    }
    //拷贝构造函数
    Student(const Student & s)
    {
        std::cout<<"拷贝构造函数"<<std::endl;
        m_age = s.m_age;
        m_name = s.m_name;
    }
    void operator=(const Student & s)
    {
        std::cout<<"赋值运算符的重载"<<std::endl;
        m_age = s.m_age;
        m_name = s.m_name;
    }

    ~Student()
    {
        std::cout<<"析构函数"<<std::endl;
    }

    void SetAge(int age);
    int GetAge();
    void SetName(const std::string& name);
    std::string GetName();
private:
    int m_age;
    std::string m_name;
};

void Student::SetAge(int age)
{
    m_age = age;
}

int Student::GetAge()
{
    return m_age;
}

void Student::SetName(const std::string &name)
{
    m_name = name;
}

std::string Student::GetName()
{
    return m_name;
}


int main()
{
    #if 1
    Student s(1,"zhangsan");
    //s.SetAge(10);
    // s.SetName("zhangsan");
    std::cout<<s.GetAge()<<" "<<s.GetName()<<std::endl;

    Student s1(s);
    std::cout<<s1.GetAge()<<" "<<s1.GetName()<<std::endl;
    
    Student s2;
    s2 = s;
    std::cout<<s2.GetAge()<<" "<<s2.GetName()<<std::endl;
    #endif
    
    return 0;
}

